home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 731 / gadtoolsbox / oberon / getfile / boopsi.s < prev    next >
Text File  |  1995-03-18  |  10KB  |  231 lines

  1.                 opt     l+,o+,ow-,inconce
  2.  
  3. *-- AutoRev header do NOT edit!
  4. *
  5. *   Program         :   GetFile.s
  6. *   Copyright       :   © Copyright 1992 Jaba Development
  7. *   Author          :   Jan van den Baard
  8. *   Creation Date   :   21-Jan-92
  9. *   Current version :   1.0
  10. *   Translator      :   Devpac 3 ( version 3.01 )
  11. *
  12. *   REVISION HISTORY
  13. *
  14. *   Date          Version         Comment
  15. *   ---------     -------         ------------------------------------------
  16. *   21-Jan-92     1.0             "GetFile" boopsi image.
  17. *
  18. *-- REV_END --*
  19.  
  20.                 incdir  "oberon:include.i/"
  21.                 include "mymacros.i"
  22.                 include "intuition/intuition.i"
  23.                 include "intuition/classes.i"
  24.                 include "intuition/classusr.i"
  25.                 include "intuition/imageclass.i"
  26.                 include "libraries/gadtools.i"
  27.  
  28.                 include "intuition/intuition_lib.i"
  29.                 include "graphics/graphics_lib.i"
  30.                 include "utility/utility_lib.i"
  31.                 include "libraries/gadtools_lib.i"
  32.  
  33.                 XDEF    _initGet
  34.                 XDEF    initGet
  35.  
  36.                 XREF    _IntuitionBase
  37.                 XREF    _GfxBase
  38.                 XREF    _UtilityBase
  39.                 XREF    _GadToolsBase
  40.  
  41.                 SECTION "getfile",CODE
  42.  
  43. ;
  44. ; --- This routine call's this class it's super class.
  45. ; --- First it get's the class it's super class in a0.
  46. ; --- Then it pushes "ourRet" on the stack which will be
  47. ; --- the return address of the superclass dispatcher.
  48. ; --- Then it pushes the lowlevel entry of the superclass
  49. ; --- dispatcher on the stack and performs an rts which
  50. ; --- causes a jump to the superclass dispatcher. When the
  51. ; --- superclass dispatcher is done it will return to "ourRet".
  52. ;
  53. callSuper:      push.l      a2                  ; save a2
  54.                 move.l      cl_Super(a0),a0     ; get superclass in a0
  55.                 pea.l       ourRet              ; push return address
  56.                 push.l      h_Entry(a0)         ; push superclass dispatcher
  57.                 rts                             ; jump to super dispatcher
  58. ourRet:         pop.l       a2                  ; restore a2
  59.                 rts
  60.  
  61. ;
  62. ; --- Initialize our private class. It set's up a class
  63. ; --- with "imageclass" as superclass.
  64. ;
  65. _initGet:
  66. initGet:        pushem.l    a2/a6               ; save registers
  67.                 move.l      _IntuitionBase,a6
  68.                 cladr       a0                  ; class ID
  69.                 lea.l       IClassName,a1       ; points to "imageclass"
  70.                 cladr       a2                  ; no superclass pointer
  71.                 cldat       d0                  ; no instance data
  72.                 cldat       d1                  ; no flags
  73.                 libcall     MakeClass           ; make the class
  74.                 move.l      d0,a0               ; put class in a0
  75.                 tst.l       d0
  76.                 beq.s       noClass             ; failed!!!
  77.                 lea.l       dispatchGet(pc),a1  ; pointer to dispatcher
  78.                 move.l      a1,h_Entry(a0)      ; set our dispatcher
  79. noClass:        popem.l     a2/a6               ; restore registers
  80.                 rts
  81.  
  82. dispatchGet:    pushem.l    d2-d7/a2-a6         ; save registers
  83.                 move.l      a0,a4               ; class to a4
  84.                 move.l      a1,a3               ; msg to a3
  85.  
  86.                 cmp.l       #OM_NEW,(a3)        ; user want a new object ?
  87.                 bne.s       noNew               ; no!
  88.  
  89.                 move.l      _UtilityBase,a6
  90.                 move.l      #GT_VisualInfo,d0   ; the tag we want
  91.                 cldat       d1                  ; default = NULL
  92.                 move.l      ops_AttrList(a3),a0 ; tags to a0
  93.                 libcall     GetTagData          ; look for the tag
  94.                 tst.l       d0                  ; tag found ?
  95.                 beq.s       newErrorV           ; no
  96.                 push.l      d0                  ; stack visualinfo
  97.  
  98.                 move.l      a4,a0               ; class to a0
  99.                 move.l      a3,a1               ; msg to a1
  100.                 bsr         callSuper           ; call the superclass
  101.                 move.l      d0,a0               ; put object in a0
  102.                 tst.l       d0
  103.                 beq.s       newErrorO           ; failed!!!
  104.                 move.w      #20,ig_Width(a0)    ; set default width
  105.                 move.w      #14,ig_Height(a0)   ; set default height
  106.                 pop.l       ig_ImageData(a0)    ; set visualInfo
  107.                 bra         Done                ; return Object
  108. newErrorO:      addq.w      #4,sp               ; restore stack
  109. newErrorV:      cldat       d0                  ; 0 for error
  110.                 bra         Done
  111.  
  112. noNew:          cmp.l       #IM_DRAW,(a3)       ; must we draw  ?
  113.                 bne         default             ; no!
  114.  
  115. draw:           cldat       d4                  ; left = 0
  116.                 cldat       d5                  ; top = 0
  117.                 moveq       #20,d6              ; width = 20
  118.                 moveq       #14,d7              ; height = 14
  119.  
  120.                 move.w      impd_OffsetX(a3),d4 ; left = x offset
  121.                 move.w      impd_OffsetY(a3),d5 ; top = y offset
  122.  
  123.                 move.l      _GfxBase,a6
  124.                 move.l      impd_RPort(a3),a5   ; rport to a5
  125.                 move.l      ig_ImageData(a2),a4 ; visualinfo to a4
  126.  
  127.                 move.l      impd_DrInfo(a3),a2  ; drawinfo to a2
  128.                 move.l      dri_Pens(a2),a2     ; drawinfo pens to a2
  129.  
  130.                 clr.l       rp_AreaPtrn(a5)     ; clear area pattern
  131.                 clr.b       rp_AreaPtSz(a5)
  132.  
  133.                 move.l      a5,a1               ; rport to a1
  134.  
  135.                 cmp.l       #IDS_SELECTED,impd_State(a3) ; draw selected ?
  136.                 bne.s       noSel               ; no!
  137.                 move.w      hifillPen*2(a2),d0  ; FILLPEN color
  138.                 bra.s       penDone
  139. noSel:          move.w      backgroundPen*2(a2),d0 ; BACKGROUNDPEN color
  140. penDone:        libcall     SetAPen             ; set the pen
  141.  
  142.                 move.l      a5,a1               ; rport to a1
  143.                 move.w      d4,d0               ; left to d0
  144.                 move.w      d5,d1               ; top to d1
  145.                 move.w      d4,d2
  146.                 add.w       d6,d2
  147.                 dec.w       d2                  ; left + width - 1 to d2
  148.                 move.w      d5,d3
  149.                 add.w       d7,d3
  150.                 dec.w       d3                  ; top + height - 1 to d3
  151.                 libcall     RectFill
  152.  
  153.                 move.l      _GadToolsBase,a6
  154.                 move.l      a5,a0               ; rport to a0
  155.                 move.l      d4,d0               ; left to d0
  156.                 move.l      d5,d1               ; top to d1
  157.                 move.l      d6,d2               ; width to d2
  158.                 move.l      d7,d3               ; height to d3
  159.                 pea.l       TAG_DONE
  160.                 cmp.l       #IDS_SELECTED,impd_State(a3) ; draw recessed ?
  161.                 bne.s       normal
  162.                 pea.l       1                   ; recessed
  163.                 pea.l       GTBB_Recessed
  164. normal:         push.l      a4
  165.                 pea.l       GT_VisualInfo
  166.                 move.l      sp,a1
  167.                 libcall     DrawBevelBoxA       ; draw the bevel box
  168.                 lea.l       12(sp),sp           ; restore stack ptr
  169.                 cmp.l       #IDS_SELECTED,impd_State(a3)
  170.                 bne.s       ok
  171.                 addq.w      #8,sp               ; restore stack a little more
  172. ok:
  173.                 move.l      _GfxBase,a6
  174.                 move.l      a5,a1               ; rport to a1
  175.                 cmp.l       #IDS_SELECTED,impd_State(a3) ; selected text pen?
  176.                 bne.s       noFPen
  177.                 move.w      hifilltextPen*2(a2),d0 ; FILLTEXTPEN color
  178.                 bra.s       setPen
  179. noFPen:         move.w      textPen*2(a2),d0    ; TEXTPEN color
  180. setPen:         libcall     SetAPen             ; set the pen
  181.  
  182.                 addq.w      #4,d4               ; set x for PolyDraw
  183.                 addq.w      #8,d5               ; set y for PolyDraw
  184.                 addq.w      #2,d5               ;  "  "  "   "   "
  185.  
  186.                 lea.l       -52(sp),sp          ; create stack space
  187.  
  188.                 moveq       #14,d0              ; 13 XY pairs
  189.                 lea.l       PolyArray(pc),a1    ; pointer to XY array in a1
  190.                 lea.l       (sp),a0             ; stack ptr to a0
  191. loopCnt:        move.w      (a1)+,(a0)          ; X to (a0)
  192.                 add.w       d4,(a0)+            ; (a0) += left
  193.                 move.w      (a1)+,(a0)          ; Y to (a0)
  194.                 add.w       d5,(a0)+            ; (a0) += top
  195.                 dbra        d0,loopCnt
  196.  
  197.                 move.l      a5,a1               ; rport to a1
  198.                 move.l      d4,d0               ; left to d0
  199.                 move.l      d5,d1               ; top to d1
  200.                 libcall     Move                ; move to this point
  201.  
  202.                 move.l      a5,a1               ; rport to a1
  203.                 move.l      sp,a0               ; array pointer in a0
  204.                 moveq       #13,d0              ; 13 XY pairs
  205.                 libcall     PolyDraw            ; draw the lines
  206.  
  207.                 lea.l       52(sp),sp           ; restore original stackptr
  208.  
  209.                 moveq       #1,d0               ; return TRUE
  210.                 bra.s       Done
  211.  
  212. default:        move.l      a4,a0               ; class to a0
  213.                 move.l      a3,a1               ; msg to a1
  214.                 bsr         callSuper           ; call superclass
  215. Done:           popem.l     d2-d7/a2-a6         ; restore registers
  216.                 rts
  217.  
  218. IClassName:     dc.b        'imageclass',0      ; superclass ID
  219.                 even
  220.  
  221. PolyArray:      dc.w        0,-6,1,-6,1,0,11,0,11,-6,9,-8,6
  222.                 dc.w        -8,4,-6,2,-6,2,-5,5,-5,6,-4,10,-4
  223.  
  224.                           even
  225. _IntuitionBase: dc.l        0
  226. _GfxBase        dc.l        0
  227. _UtilityBase    dc.l        0
  228. _GadToolsBase   dc.l        0
  229.  
  230.                                 end
  231.